$(function() {
    var arr = decodeURI(location.search).split("?");
    var arrU = arr[1].split("&");
    var obj = {};
    for (var i = 0; i < arrU.length; i++) {
        var arrur = arrU[i].split("=");
        obj[arrur[0]] = arrur[1];
    }

    function getproductDec() {
        $.ajax({
            type: 'get',
            url: 'http://localhost:3000/api/getproduct',
            dataType: 'json',
            data: {
                productid: obj.productId
            },
            success: function(res) {
                var arrDec = [res.result];
                var objDec = { result: arrDec }
                console.log(objDec)
                $(".product-dec").html(template("product-dateil", objDec))
            }
        })
    }
    getproductDec()

    function getCompareList() {
        $.ajax({
            type: 'get',
            url: 'http://localhost:3000/api/getproductcom',
            data: {
                productid: obj.productId,
                category: obj.category
            },
            dataType: 'json',
            success: function(res) {
                console.log(res)
                $(".com-list-area").html(template("com-list", res))
            }
        })
    }
    getCompareList()
})